package com.dmw.service.impl;

import com.dmw.dao.DmItemCommentDao;
import com.dmw.entity.DmItemComment;
import com.dmw.service.DmItemCommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 剧评表(DmItemComment)表服务实现类
 *
 * @author makejava
 * @since 2021-03-19 00:31:54
 */
@Service("dmItemCommentService")
public class DmItemCommentServiceImpl implements DmItemCommentService {
    @Resource
    private DmItemCommentDao dmItemCommentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public DmItemComment queryById(Long id) {
        return this.dmItemCommentDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<DmItemComment> queryAllByLimit(int offset, int limit) {
        return this.dmItemCommentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param dmItemComment 实例对象
     * @return 实例对象
     */
    @Override
    public DmItemComment insert(DmItemComment dmItemComment) {
        this.dmItemCommentDao.insert(dmItemComment);
        return dmItemComment;
    }

    /**
     * 修改数据
     *
     * @param dmItemComment 实例对象
     * @return 实例对象
     */
    @Override
    public DmItemComment update(DmItemComment dmItemComment) {
        this.dmItemCommentDao.update(dmItemComment);
        return this.queryById(dmItemComment.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.dmItemCommentDao.deleteById(id) > 0;
    }
}
